/**
 * Author: Shen Yanqiu
 * Date: 2017-12-06
 * Time: 12:22
 *
 */
import configs from '../src/config';
import Mock from "mockjs";

const { mockAPIPrefix } = configs;

let expenditureListData = Mock.mock({
  'data|80-100': [
    {
      id: '@id',
      content: '@cname',
      status: `已通过`,
      owner: `我自己发起的`,
      time: '@datetime',
    },
  ],
});
let expenditure = expenditureListData.data;
export default {

  [`GET ${mockAPIPrefix}/expenditure/list`] (req, res) {

    let { pageSize, page, ...otherArgs } = req.query;
    pageSize = pageSize || 10;
    page = page || 1;
    let data = expenditure.slice((page - 1) * pageSize, page * pageSize);
    setTimeout(() => {
      res.json({
        success: true,
        data: {
          list: data,
          total: expenditure.length,
        },
      });
    }, 2000);
  },
  [`GET ${mockAPIPrefix}/expenditure/details`] (req, res) {
    const data = {
      info: {
        status: '-1',
        bumen: '新闻部',
        user: '张三',
        uid: 1234123421,
        mudi: '用于购买三球联赛的产品',
        feiyong: 1000,
        time: '2016-10-26',
      },
      images: [{
        url: 'https://os.alipayobjects.com/rmsportal/QBnOOoLaAfKPirc.png',
        alt: 'example',
      }, {
        url: 'http://qspinach.cn/build/images/138012-20161016201638030-473660627.png',
        alt: 'example',
      }, {
        url: 'https://os.alipayobjects.com/rmsportal/QBnOOoLaAfKPirc.png',
        alt: 'example',
      }],
      files: [{
        filename: 'test.doc',
        url: 'http://www.qspinach.cn/syq/test.doc',
      }],
    };
    let { detailsId } = req.query;
    // console.log(detailsId);
    setTimeout(() => {
      res.json({
        success: true,
        data: {
          details: data,
        },
      });
    }, 2000);
  },
};
